package com.jjclub.controller;

import com.jjclub.entity.Test;
import com.jjclub.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;



/**
 * @Classname IndexController
 * @Description TODO
 * @Date 2019/10/11 9:52
 * @Created by jq
 */

@Controller
@Api(value = "测试框架",description = "学生接口")
public class IndexController {

    @Autowired
    private TestService testService;

    /***
     * description:测试首页
     * @param: []
     * @author: jj
     * @date: 2019/10/11 9:52
     * @return java.lang.String
     **/
    @ApiOperation(value = "index测试" ,  notes="首页测试")
    @PostMapping("index")
    @ResponseBody
    public String index(){
        Test rs = null;
        try {
            rs = testService.getList();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return rs.toString();
    }
    /***
     * description:测试前端模板
     * @param: []
     * @author: jj
     * @date: 2019/10/16 9:36
     * @return java.lang.String
     **/
    @ApiOperation(value = "index页面",notes ="thymelraf测试")
    @GetMapping("index")
    public String indexs(Model model){
        model.addAttribute("name","success!");
        return "index";
    }
}
